import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:"/home/index"
  },
  {
    path:"/home",
    component:()=>import("../views/home/home"), // 承接二级路由的页面
    children:[
        {
          path:"/home/index", // 首页
          component:()=>import("../views/home/index")
        },
        {
          path:"/home/shopcar",
          component:()=>import("../views/home/shopcar")
        },
        {
          path:"/home/address",
          component:()=>import("../views/home/address")
        }
    ]
  },
  {
    path:"/detail/:id",// 动态路由，id 用于站位。根据传的参数生成
    component:()=>import("../views/Detail")
  },
  {
    path:"/login",
    component:()=>import("../views/Login")
  },
  {
    path:"/addaddress",
    component:()=>import("../views/home/addaddress")
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
